package com.hiray.demos.ui_architect.litho.list

import com.facebook.litho.sections.Children
import com.facebook.litho.sections.SectionContext
import com.facebook.litho.sections.annotations.GroupSectionSpec
import com.facebook.litho.sections.annotations.OnCreateChildren
import com.facebook.litho.sections.common.SingleComponentSection

@GroupSectionSpec
object ListSectionSpec {

    @OnCreateChildren
    fun onCreateChildren(c: SectionContext): Children {
        val builder = Children.create()
        for (i in 0..32) {
            builder.child(
                    SingleComponentSection.create(c)
                            .key(i.toString())
                            .component(ListItem.create(c)
                                    .title("item $i")
                                    .subTitle("subtitle:$i")
                                    .build())
            )
        }
        return builder.build()
    }
}